package com.yhsimon.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//死信队列
@Configuration
public class DeadRabbitMqConfiguration {
    //1.声明注册fanout模式的交换机
    @Bean
    public DirectExchange deadExchange(){
        return new DirectExchange("dead_direct_exchange",true,false);
    }


    //2. 声明死信队列
    @Bean
    public Queue deadQueue(){
        return new Queue("dead.direct.queue",true);
    }


    //3.完成绑定关系（队列与交换机完成绑定关系）
    @Bean
    public Binding deadBinding(){
        return BindingBuilder.bind(deadQueue()).to(deadExchange()).with("dead");
    }

}
